/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import {
  Row,
  Col,
  Form,
  Input,
  DatePicker
} from 'antd';
const FormItem = Form.Item;
const formItemLayout = {
  // 抽屉里面Form。二列的布局比例
  labelCol: {
    span: 6
  },
  wrapperCol: {
    span: 18
  }
};

class AddFrom extends PureComponent {

  changModel = (e) => {
    const {
      form: { getFieldsValue },
      onchangModel
    } = this.props;

    if (onchangModel) {
      onchangModel(getFieldsValue());
    }
  };
  render() {
    const {
      formData,
      operateType,
      form: { getFieldDecorator },
    } = this.props;
    return (
      <Form >
        <Row>
          <Col span={24}>
            <FormItem {...formItemLayout} label={'批号'}>
              {getFieldDecorator('batchNo', {
                initialValue: formData.batchNo || '',
                rules: [
                  {
                    required: true,
                    message: '请输入批号'
                  }
                ]
              })(<Input placeholder='请输入批号'/>)}
            </FormItem>
          </Col>
          <Col span={24}>
            <FormItem {...formItemLayout} label={'机型'}>
              {getFieldDecorator('productModelName', {
                initialValue: formData.productModelName || '',
                rules: [
                  {
                    required: true,
                    message: '请选择机型'
                  }
                ]
              })(<Input placeholder='请选择机型' onClick={this.changModel} />)}
            </FormItem>
          </Col>
          {<Col span={24}>
            <FormItem {...formItemLayout} label={'期望验收时间'}>
              {getFieldDecorator('acceptanceHopeTime', {
                initialValue: formData.acceptanceHopeTime || undefined,

              })(<DatePicker
                style={{ width: '100%' }}
                showTime={true}
                format="YYYY-MM-DD HH:mm:ss"
              />)}
            </FormItem>
          </Col>}

        </Row>
        <FormItem style={{ visibility: 'hidden' }}>
          {getFieldDecorator('id', {
            initialValue: formData?.id || null,
          })(
            <Input />
          )}
        </FormItem>
        <FormItem style={{ visibility: 'hidden' }}>
          {getFieldDecorator('productModel', {
            initialValue: formData?.productModel || null,
          })(
            <Input />
          )}
        </FormItem>
      </Form>
    );
  }
}

export default Form.create()(AddFrom);
